<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>餐厅扫码点餐系统 - SmartOrder</title>
    <link rel="stylesheet" href="/css/element-ui.css">
    <style>
        body {
            font-family: Avenir, Helvetica, Arial, sans-serif;
            color: #2c3e50;
        }

        a {
            color: #2c3e50;
            text-decoration: none;
        }

        a:hover {
            color: #409eff;
            text-decoration: none;
        }

        .footer {
            background-color: #f56c6c;
            color: white;
            font-size: 18px;
            line-height: 54px;
            text-align: center;
            margin-top: 20px;
        }
    </style>
</head>
<body>
<div id="app" style="text-align: center;">
    <h1>欢迎光临，请扫描您的餐桌上的二维码开始点餐（测试阶段，将显示所有桌的二维码）</h1>
    <el-row :gutter="20" style="margin-top: 20px;">
        <el-col :span="4" v-for="table in tables" :key="table.id">
            <a :href="'make_order.html?tableId=' + table.id" style="display: block;">
                <el-card :body-style="{ padding: '0px' }" style="margin: 10px 0;">
                    <el-image
                            style="width: 200px; height: 200px"
                            :src="table.qrCodePath"
                            fit="fill"></el-image>
                    <div style="padding: 14px;">
                        <span style="font-size: 28px;">{{ table.id }}桌</span>
                    </div>
                </el-card>
            </a>
        </el-col>
    </el-row>
</div>
<div class="footer">
    当前页面由AI自动生成，可能需要进一步优化或调整。
</div>
<!-- 引入Vue.js -->
<script src="/js/vue.js"></script>
<!-- 引入Element-UI -->
<script src="/js/element-ui.js"></script>
<!-- 引入AXIOS -->
<script src="/js/axios.min.js"></script>
<script>
    console.log('页面加载中...');
    new Vue({
        el: '#app',
        data: {
            tables: []
        },
        created() {
            console.log('获取餐桌列表...');
            this.fetchTables();
        },
        methods: {
            fetchTables() {
                axios.get('/api/diningTables')
                    .then(response => {
                        console.log('获取餐桌列表成功:', response.data);
                        this.tables = response.data;
                    })
                    .catch(error => {
                        console.error('获取餐桌列表失败:', error);
                    });
            }
        }
    });
</script>
</body>
</html>